package gcontent.utils;

import java.util.*;

public class Dates {
	public static java.sql.Date getSQLDate(Calendar calendar) {
		return new java.sql.Date(calendar.getTime().getTime());
	}
	
	public static Calendar getFirstDayOfMonth() {
		Calendar cal = GregorianCalendar.getInstance();
		cal.set(Calendar.DAY_OF_MONTH, 1);
		return cal;
	}
	
	public static Calendar getFirstDayOfYear() {
		Calendar cal = GregorianCalendar.getInstance();
		cal.set(Calendar.DAY_OF_YEAR, 1);
		return cal;
	}
	
	public static Calendar getLastDayOfYear() {
		Calendar cal = GregorianCalendar.getInstance();		
		cal.set(Calendar.MONTH, 12);
		cal.set(Calendar.DAY_OF_MONTH, 31);
		return cal;
	}
	
	public static Calendar getLastDayOfMonth() {
		Calendar cal = GregorianCalendar.getInstance();
		int day = cal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH);
		cal.set(Calendar.DAY_OF_MONTH, day);
		return cal;
	}
}
